import 'package:flutter/material.dart';

/// @author longzipeng
/// @创建时间：2022/3/15
/// 基于ListTitle的二次封装
class ListTitleWidget extends StatelessWidget {
  final Widget? title;
  final Widget? leading;
  final Widget? trailing;
  final GestureTapCallback? onTap;
  final bool showDivider; // 是否显示分割线

  const ListTitleWidget(
      {Key? key,
      this.title,
      this.leading,
      this.trailing,
      this.onTap,
      this.showDivider = true})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        /// 列表内容
        ListTile(
          title: title,
          leading: leading,
          trailing: trailing ??
              (onTap != null ? const Icon(Icons.arrow_forward_ios) : trailing),
          onTap: onTap,
        ),

        /// 分割线
        if (showDivider)
          Divider(
            height: 1,
            thickness: 1,
            indent: 2,
            endIndent: 2,
            color: Theme.of(context).dividerColor,
          ),
      ],
    );
  }
}
